home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 3 / Amiga Format CD03 (1996-07-04)(Future Publishing)(GB)(Track 1 of 6)[!][issue 1996-08].iso / comms / netsoftware / archie38_1.lha / archie-1.4 / vl_comp.c < prev    next >
C/C++ Source or Header  |  1995-01-05  |  2KB  |  83 lines

  1. /*
  2.  * Copyright (c) 1989, 1990, 1991 by the University of Washington
  3.  *
  4.  * For copying and distribution information, please see the file
  5.  * <copyright.h>.
  6.  */
  7. /* Amiga port by Tomas Willis (tomas@cae.wisc.edu) January 1995 */
  8.  
  9. #include "pfs.h"
  10. #include "string.h"
  11.  
  12. //protos
  13. int vl_comp(VLINK vl1, VLINK vl2);
  14. int vl_equal(VLINK vl1, VLINK vl2);
  15.  
  16. //extern
  17.  
  18.  
  19.  
  20. /*
  21.  * vl_comp - compare the names of two virtual links
  22.  *
  23.  *           VL_COMP compares the names of two links.  It returns
  24.  *           0 if they are equal, negative if vl1 < vl2, and positive if
  25.  *           vl1 > vl2.
  26.  *
  27.  *    ARGS:  vl1,vl2 - Virtual links to be compared
  28.  *
  29.  * RETURNS:  0 if equal, + is vl1 > vl2, - if vl1 < vl2
  30.  *
  31.  *   NOTES:  Order of significance is as follows.  Existence,
  32.  *           name.  If names do not exist, then hosttype, host,
  33.  *           native filenametype, native filename.  The only time
  34.  *           the name will not exist if if the link is a union link.
  35.  */
  36. int
  37. vl_comp(VLINK vl1, VLINK vl2)
  38. //    VLINK    vl1;
  39. //    VLINK    vl2;
  40. {
  41.     int    retval;
  42.  
  43.     if(vl1->name && !vl2->name) return(1);
  44.     if(!vl1->name && vl2->name) return(-1);
  45.     if(vl1->name && vl2->name && (*(vl1->name) || *(vl2->name)))
  46.         return(strcmp(vl1->name,vl2->name));
  47.  
  48.     retval = strcmp(vl1->hosttype,vl2->hosttype);
  49.     if(!retval) retval = strcmp(vl1->host,vl2->host);
  50.     if(!retval) retval = strcmp(vl1->nametype,vl2->nametype);
  51.     if(!retval) retval = strcmp(vl1->filename,vl2->filename);
  52.     return(retval);
  53. }
  54.  
  55. /*
  56.  * vl_equal - compare the values of two virtual links
  57.  *
  58.  *           VL_EQUAL compares the values of two links.  It returns
  59.  *           1 if all important fields are the same, and 0 otherwise.
  60.  *
  61.  *    ARGS:  vl1,vl2 - Virtual links to be compared
  62.  *
  63.  * RETURNS:  1 if equal, 0 if not equal
  64.  *
  65.  */
  66. int
  67. vl_equal(VLINK vl1, VLINK vl2)
  68. //    VLINK    vl1;
  69. //    VLINK    vl2;
  70. {
  71.       return strcmp(vl1->name, vl2->name) == 0         &&
  72.          vl1->linktype == vl2->linktype            &&
  73.          strcmp(vl1->type, vl2->type) == 0         &&
  74.          strcmp(vl1->hosttype, vl2->hosttype) == 0 &&
  75.          strcmp(vl1->host, vl2->host) == 0         &&
  76.          strcmp(vl1->nametype, vl2->nametype) == 0 &&
  77.          strcmp(vl1->filename, vl2->filename) == 0 &&
  78.          vl1->version == vl2->version              &&
  79.          vl1->f_magic_no == vl2->f_magic_no        ;
  80.  
  81. }
  82.  
  83.